//
//  DyAFnetWorking.m
//  AFN封装demol
//
//  Created by dllo on 15/11/25.
//  Copyright © 2015年 大远. All rights reserved.
//

#import "DyAFnetWorking.h"

@implementation DyAFnetWorking

+ (void)POSTAfnNetworkingWithUrl:(NSString *)url WithParameters:(NSDictionary *)para Block:(void (^)(id result))block{
    
    AFHTTPSessionManager *netManager = [AFHTTPSessionManager manager];
    netManager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html",@"text/css",@"text/plain",@"application/x-javascript",nil];
   [netManager POST:url parameters:para success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
       block(responseObject);
   } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
       UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您当前网络不佳" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
       [alterView show];
       NSLog(@"失败==== %@",error);
   }];
}
+ (void)GETJRAfnNetworkingWithUrl:(NSString *)url Block:(void (^)(id result))block {
    AFHTTPSessionManager *mannager = [AFHTTPSessionManager manager];
    [mannager.responseSerializer setAcceptableContentTypes: [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html",@"text/css",@"text/plain",@"application/x-javascript",nil]];
    [mannager GET:url parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        block(responseObject);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您当前网络不佳" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alterView show];
        NSLog(@"失败==== %@",error);
    }];
}
@end
